void get(struct TreeNode* root, int* a, int* i)
{
    if (root == NULL)
        return;
    if (root->left == root->right)
    {
        a[*i] = root->val;
        *i = *i + 1;;
    }
    get(root->left, a, i);
    get(root->right, a, i);
}


bool leafSimilar(struct TreeNode* root1, struct TreeNode* root2) {
    int* a = (int*)malloc(sizeof(int) * 200);
    int* b = (int*)malloc(sizeof(int) * 200);
    int i = 0;
    get(root1, a, &i);
    int j = 0;
    get(root2, b, &j);
    if (i != j)
        return false;
    for (int n = 0; n < i; n++)
    {
        if (a[n] != b[n])
            return false;
    }
    return true;

}